import 'package:flutter/material.dart';
import 'package:word_card/pages/test.dart';
import 'package:word_card/pages/test1.dart';
import 'package:word_card/pages/test2.dart';
import 'package:word_card/pages/test3.dart';

class Index extends StatefulWidget {
  const Index({Key? key}) : super(key: key);

  @override
  State<Index> createState() => _IndexState();
}

class _IndexState extends State<Index> {
  int currentIndex = 0;
  final List<Widget> tabBodies = [
    const TestPage(),
    const TestFirst(),
    const TestSecond(),
    const TestThird()
  ];

  final List<BottomNavigationBarItem> bottomTabs = [
    const BottomNavigationBarItem(
        icon: Padding(
          padding: EdgeInsets.all(8.0),
          child: Icon(Icons.home),
        ),
        label: 'test',
        tooltip: ""),
    const BottomNavigationBarItem(
        icon: Icon(Icons.list), label: 'test1', tooltip: ""),
    const BottomNavigationBarItem(
        icon: Icon(Icons.accessibility_outlined), label: 'test2', tooltip: ""),
    const BottomNavigationBarItem(
        icon: Icon(Icons.person), label: 'test3', tooltip: ""),
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('demo'),
      ),
      body: IndexedStack(
        index: currentIndex,
        children: tabBodies,
      ),
      bottomNavigationBar: BottomNavigationBar(
        selectedItemColor: Colors.black,
        unselectedItemColor: Colors.black26,
        currentIndex: currentIndex,
        items: bottomTabs,
        onTap: (index) {
          setState(() {
            currentIndex = index;
          });
        },
      ),
    );
  }
}
